export default {};

type ObjType = {
  name: string;
  age: number;
  gender?: number;
  //   只需要描述清楚是函数即可，无论怎么定义的都可以
  //   sayHi(): void;
  //   sayHello(): void;
  sayHi: () => void;
  sayHello: () => void;
  add: (a: number, b: number) => number;
};

const obj1: ObjType = {
  name: 'zs',
  age: 20,
  sayHi() {},
  sayHello: () => {},
  add(a, b) {
    return a + b;
  },
};
obj1.add(10, 20);
// 不建议把方法也变成可选
console.log('obj1.gender -----> ', obj1.gender);
console.log('obj1.gender -----> ', obj1.sayHi());
